<?php
/**
* Project: VsPhpFm 
* Package: VsCore
* File: vslocale_factory.php
*
* Version: 1.0
* Date: 20th June, 2008
* ------------------------
*
* Author: Ivan i. Atanasov johnny2000@abv.bg
*
*/

require_once(DIR_LIB."vslibdef.php");

if(!defined('DIR_LIB_VSCORE'))
	define('DIR_LIB_VSCORE', DIR_LIB."VsCore".DIR_SEP);

require_once(DIR_LIB_VSCORE."db.php");

class VsLocaleFactory {

	private static $_Instance = NULL;

	private $_defaultLocale = '';
	private $_currentLocale = '';
	private $_listLocales = array();

	var $_db = NULL;
	var $_sqlTable='locales';

	static function Instance() {
		if(!self::$_Instance)
			self::$_Instance = &new VsLocaleFactory();

		return self::$_Instance;
	}
	//====================================================================================

	public static function Locales() {
		$db = VsDatabase::Instance();
		$locale = new VsLocale;

		$q = "SELECT * FROM `locales`";

		$res = $db->query($q);
		while($rLocale=mysql_fetch_object($res)) {
			$locale = new VsLocale;

			$locale->_code = $rLocale->code;
			
		}

		return $locale;

	}
	//====================================================================================

	public static function Locale($code) {
		$db = VsDatabase::Instance();
		$locale = new VsLocale;

		$q = "SELECT * FROM `locales` WHERE code=".$code;

		$res = $db->query($q);
		while($rLocale=mysql_fetch_object($res)) {
			$locale->_code = $rLocale->code;
			
		}

		return $locale;
	}
	//====================================================================================

	private function __construct() {
		$this->_db = VsDatabase::Instance();

		
	}
	//====================================================================================

	function code() {
		return $this->_code;
	}
	//====================================================================================

	function flag() {
		return $this->_flag;
	}
	//====================================================================================

	function name($locale) {
		return $this->_names[$locale];
	}
	//====================================================================================


};


?>